//0〜n-1中缺失的数字
public class leetcode173 {
    public int takeAttendance(int[] records) {
        // if(records[0]!=0){
        //     return 0;
        // }
        // int i=0;
        // for(;i<records.length-1;i++){
        //     if(records[i+1]-records[i]>1){
        //         return records[i]+1;
        //     }
        // }
        // return records[i]+1;
        int left=0;
        int right=records.length-1;
        while(left<right){
            int mid=left+(right-left)/2;
            if(records[mid]==mid){
                left=mid+1;
            }else{
                right=mid;
            }
        }
        if(records[left]==left){
            return left+1;
        }else{
            return left;
        }
    }
}
